package common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;

import org.junit.Test;

import domain.Admin;
import domain.User;

public class Constants {
	
	private static SimpleDateFormat sdfwithWithTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");  
	private static String RESOURCE = "config";
	private static String DEFAULT_SCHEMA = "default_schema";
	public static List<User> EMPTY_LIST = new ArrayList<User>(0);
	public static List<Admin> EMPTY_ADMIN_LIST = new ArrayList<Admin>(0);
	
	public static Date parseDate(String date) throws ParseException{
		return sdf.parse(date);
	}
	
	public static String getCurrentDateTime() throws ParseException{
		Calendar cal = Calendar.getInstance();
		Date dateTime = cal.getTime();
		return sdfwithWithTime.format(dateTime);
	}
	
	// String -> Date
	public static Date getDateFromStringDate(String dateTime) throws ParseException{
		return sdfwithWithTime.parse(dateTime);
	}
	
	public static Date getDateFromStringDate() throws ParseException{
		return sdfwithWithTime.parse(getCurrentDateTime());
	}
	
	public static String getDefaultSchema(){
		String default_schema = ResourceBundle.getBundle(RESOURCE).getString(DEFAULT_SCHEMA);
		return default_schema;
	}
	
	@Test
	public void test() throws ParseException{
		String dString = getCurrentDateTime();
		System.out.println(dString);
		Date dd = getDateFromStringDate(dString);
		System.out.println(dd);
		
	}
}
